package Search;

import java.util.ArrayList;

import Main.Node;

public class DFS extends GSearch {

	static ArrayList<Node> Q = new ArrayList<Node>();

	public static void search(Node InitialBoard) {
		Q.add(InitialBoard);

		while (!Q.isEmpty() && !Solved(Q.get(0))) {
			ArrayList<Node> x = expand(Q.remove(0));
			while (!x.isEmpty()) {
				if (GSearch.checkDone(x.get(0).getBoard().getB())) {
					Q.add(0, x.get(0));
				}
				x.remove(0);
			}
		}
		if (!Q.isEmpty()) {
			displayPath(formPath(Q.get(0)));
			System.out.println("SOLUTION!!!");
		}else {
			System.out.println("NO SOLUTION!!!");
		}

	}
}
